function e(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

function t(e, t, n) {
    return t in e ? Object.defineProperty(e, t, {
        value: n,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[t] = n, e;
}

Object.defineProperty(exports, "__esModule", {
    value: !0
});

var n = e(require("../component")), a = function(e) {
    for (var t = [], n = 0; n < e.length; n++) {
        var a = e[n];
        "请选择" !== a.name && t.push(a.name);
    }
    return t.length ? t : [ "" ];
}, u = function(e) {
    return e.sub ? a(e.sub) : [ "" ];
}, i = function(e) {
    for (var t = 0; t < o.length; t++) if (o[t].name === e) return u(o[t]);
    return [ "" ];
}, r = function(e, t) {
    for (var n = 0; n < o.length; n++) if (o[n].name === e) for (var a = 0; a < o[n].sub.length; a++) if (o[n].sub[a].name === t) return u(o[n].sub[a]);
    return [ "" ];
}, o = e(require("./data")).default, l = o.map(function(e) {
    return e.name;
}), s = l[0], c = u(o[0]), v = c[0], d = r(s, v);

d[0];

exports.default = {
    setDefaults: function() {
        return {
            title: "请选择",
            cols: [ {
                values: l,
                className: "col-province"
            }, {
                values: c,
                className: "col-city"
            }, {
                values: d,
                className: "col-district"
            } ],
            value: [],
            toolbar: !0,
            toolbarCloseText: "完成",
            onChange: function() {}
        };
    },
    temp: {},
    init: function(e) {
        var a = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, u = this, o = function() {
            for (var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [], t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : [], n = [], a = [], u = [], i = 0; i < e.length; i++) if (e[i]) {
                var r = e[i].values || [], o = e[i].displayValue || [], l = t[i];
                a.push(void 0 !== r[l] ? l : 0), n.push(void 0 !== r[l] ? r[l] : r[0]), u.push(void 0 !== o[l] ? o[l] : void 0);
            }
            return !(n.indexOf(void 0) >= 0) && {
                value: n,
                valueIndex: a,
                displayValue: u
            };
        }, l = u.temp[e] = u.temp[e] ? u.temp[e] : {
            currentProvince: s,
            currentCity: v
        }, c = Object.assign({}, this.setDefaults(), a);
        c.value = o(c.cols, c.value).valueIndex, c.cols = l && l.cols || c.cols;
        var d = new n.default({
            scope: "$wux.pickerCity." + e,
            data: c,
            methods: {
                hide: function(e) {
                    this.setHidden([ "weui-animate-slide-down", "weui-animate-fade-out" ]);
                },
                show: function() {
                    this.setVisible([ "weui-animate-slide-up", "weui-animate-fade-in" ]);
                },
                bindChange: function(e) {
                    this.render(e.detail.value);
                },
                updateValue: o,
                render: function() {
                    var n = this, a = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [], u = this.getComponentData().cols, o = u[0].values[a[0]], s = void 0, v = !1;
                    if (o !== l.currentProvince) {
                        var d = i(o);
                        s = d[0];
                        var f = r(o, s);
                        u[1].values = d, u[2].values = f, l.currentProvince = o, l.currentCity = s, v = !0;
                    }
                    var h = u[1].values[a[1]];
                    if (!v && h !== l.currentCity) {
                        var p = r(o, s = h);
                        u[2].values = p, l.currentCity = s;
                    }
                    !function(a, u) {
                        var i, r = n.updateValue(a, u);
                        n.setData((i = {}, t(i, "$wux.pickerCity." + e + ".cols", a), t(i, "$wux.pickerCity." + e + ".value", r.valueIndex), 
                        i)), "function" == typeof c.onChange && c.onChange(r);
                    }(u, a), l.value = a, l.cols = u;
                }
            }
        });
        d.show(), d.render(l && l.value || c.value);
    }
};